<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
			www.wrecruit.com, developer@wrecruit.com
 * Created on:	Oct 2nd, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/wrecruitsearch.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		1.0.3 - Mar 21, 2012
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

$document = &JFactory::getDocument();
//$document->addScript( JURI::base() . '/includes/js/joomla.javascript.js');

JHTML :: _('behavior.calendar');
	$version = new JVersion;
	$joomla = $version->getShortVersion();
	$jversion = substr($joomla,0,3);


$sh_category = $params->get('category', 1);
$sh_jobtype = $params->get('jobtype', 1);
$sh_jobstatus = $params->get('jobstatus', 1);
$sh_company = $params->get('company', 1);
$sh_addresses = $params->get('addresses', 1);
$sh_salaryrange = 0;
$sh_shift = 0;

//scs				
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else  $itemid =  JRequest::getVar('Itemid');
//sce

$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
$divclass=array('odd','even');

require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array(
	'table_path' => $componentAdminPath . DS . 'tables'
);
$model = new WRecruitModelMpWRecruit($config);
$result = $model->jobsearch($sh_category,$sh_company,$sh_jobtype,$sh_jobstatus,$sh_shift,$sh_salaryrange);

$js_dateformat = $result[0];
$currency = !empty($result[1]) ? $result[1] : '';
$job_categories = !empty($result[2]) ? $result[2] : '';
$search_companies = !empty($result[3]) ? $result[3] : '';
$job_type= !empty($result[4]) ? $result[4] : '';
$job_countries = !empty($result[10]) ? $result[10] : '';
	
?>
<h2>Quick Job Search</h2>
<form action="<?php echo JRoute::_('index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=job_searchresults&Itemid='. $itemid);?>" method="post" name="mjsadminForm" id="mjsadminForm">
	<input type="hidden" name="isjobsearch" value="1" />
	<ul class="box-search">
		<li class="search-text">
			<input class="text" type="text" name="keyword" size="27" maxlength="255"  />
		</li>
		<?php
		//print_r();exit;
		if ( $sh_category == 1 ) {
			echo '<li class="search-select">' . $job_categories . '</li>';
		}
		if ( $sh_jobtype == 1 ) {
			echo '<li class="search-select">' . $job_type . '</li>';
		}
		if ( $sh_company == 1 ) {
			echo '<li class="search-select">' . $search_companies . '</li>';
		}
		if ( $sh_addresses == 1 ) {
			echo '<li class="search-select">' . $job_countries . '</li>';
		}
		?>
		<li class="submit">
			<input type="submit" class="button-search" name="submit_app" onclick="document.mjsadminForm.submit();" value="" />
		</li>
	</ul>
	<input type="hidden" name="view" value="jobseeker" />
	<input type="hidden" name="layout" value="job_searchresults" />
	<input type="hidden" name="uid" value="" />
	<input type="hidden" name="option" value="com_wrecruit" />
</form>
<div class="job-link">
	<span class="job-link-text">More to access to your intersting job:</span>
	<?php
		$link_browse = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=browsejobs&jobcat=&Itemid='.$itemid; 
		$link_search = 'index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=jobsearch&Itemid='.$itemid;
	?>
	<a href="<?php echo JRoute::_($link_browse) ?>">Browse Job</a> <span class="separate">|</span> <a href="<?php echo JRoute::_($link_search) ?>">Advanced Search</a>
</div>

